package gtkwire.gobject;

/**
* This class makes it possible to achieve per cell rendering. Cell renderers 
* extending GtkCellRenderer render all the cells in a column using same property values.
* Override cellRenderCallBack(), and use setCurrentCellProperty() to set property values for each cell.
* See GTK+ documentation to see what properties are available for each cellrenderer type.
* <p>
* Example of setting property value to get orange backgroung for cell: setCurrentCellProperty( "cell-background", GType.STRING, "Orange" );
* <P>
* Because of callback and methods calls to set property values for every cell, rendering performance is worse then what you get from a cellrenderer.
*/
public abstract class GtkCellDataFunc
{
	private int data_func_id;
	private static int next_data_func_id = 0;

	/**
	* Creates id for objrct.
	*/
	protected void init()
	{
		data_func_id = next_data_func_id;
		next_data_func_id++;
	}

	/**
	* Override to implement cell rendering functionality. This is called once for every target cell when gui update is needed.
	* Path is the address of row this column is part of. 
	*/
	public abstract void cellRenderCallBack( int cellRendererId, String path );

	/**
	* Sets current cells property values.
	*/ 
	public void setCurrentCellProperty( String property, GType type, String value )
	{
		GtkTreeModel.set_cell_property( property, type.getCode(), value );
	}

	/**
	* Returns id of this object.
	*/ 
	public int getId(){ return data_func_id; }

}//end class